<?php
 /*
 * 1626cms 管理員賬戶
 * ============================================================================
 * 版權所有: 1626網絡，并保留所有權利。
 * 網站地址: http://www.1626.com；
 * ----------------------------------------------------------------------------
 * 這不是一個自由軟件！您只能在不用于商業目的的前提下對程序代碼進行修改和
 * 使用；不允許對程序代碼以任何形式任何目的的再發布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once('../data/config.php');
require_once('./include/admin_common.inc.php');
require_once(ADMIN_ROOT_PATH.'include/admin_account_fun.php');
!empty($_POST['perpage'])?(setcookie('perpage',intval($_POST['perpage']))).($perpage=intval($_POST['perpage'])):($perpage= !empty($_COOKIE['perpage'])? $_COOKIE['perpage'] :'10');
$act = !empty($_REQUEST['act']) ? trim($_REQUEST['act']) : 'list';
//登錄日志列表
if($act == 'list'){
require_once(ADMIN_ROOT_PATH.'include/page.class.php');
$wheresql=" WHERE admin_name='".$_SESSION['admin_name']."'";
$total_sql="SELECT COUNT(*) AS num FROM ".table('admin_log').$wheresql;
$total_val=get_total($total_sql);
$page = new page(array('total'=>$total_val, 'perpage'=>$perpage));
$currenpage=$page->nowindex;
$offset=($currenpage-1)*$perpage;
$list = get_admin_log($offset,$perpage,$wheresql);
$smarty->assign('pageheader',"管理中心 - 登錄日志");
$smarty->assign('list',$list);//列表
$smarty->assign('perpage',$perpage);//每頁顯示數量POST
if ($total_val>$perpage)
{
$smarty->assign('page',$page->show(3));//分頁符
}
$smarty->display('admin_admin_log.htm');
}
//刪除日期
if($act == 'log_del'){
if ($_POST['delete'])
{
!del_log($_SESSION['admin_name'],30)?showmsg("刪除失敗！",1):showmsg("刪除成功！",2);
}
}
//修改密碼
if($act == 'edit_pwd'){
$id=intval($_GET['$id']);
if ($id=='') $id=$_SESSION['admin_id'];
$account=get_admin_account($id);
if ($account['admin_name']<>$_SESSION['admin_name'])
{//如果是普通管理員，則只可以修改自己的密碼
if ($_SESSION['purview']<>"all")showmsg("您沒有權限修改密碼！",1);
}
$smarty->assign('admin',$account);
$smarty->assign('pageheader',"管理中心 - 修改密碼");
$smarty->display('admin_edit_pwd.htm');
}
//保存修改的密碼
if($act == 'pwd_edit_save'){
$id=trim($_POST['id'])?trim($_POST['id']):showmsg('參數錯誤！',1);
$edit_admin_name=trim($_POST['edit_admin_name'])?trim($_POST['edit_admin_name']):showmsg('參數錯誤！',1);
$old_pwd=trim($_POST['old_pwd'])?trim($_POST['old_pwd']):showmsg('請輸入舊密碼！',1);
$password=trim($_POST['password'])?trim($_POST['password']):showmsg('請輸入新密碼！',1);
strlen($password)<6?showmsg('新密碼長度不能少于6位！',1):'';
($password<>trim($_POST['password1']))? showmsg('兩次輸入的密碼不相同！',1):'';
!check_admin($edit_admin_name,$old_pwd)?showmsg('舊密碼輸入錯誤！',0):'';
!edit_admin_account($edit_admin_name,$password)?showmsg('修改失敗！',0):showmsg('成功修改！',2);
}

?>
